/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author damfercer
 */
@Entity
@Table(name = "desired_salary")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DesiredSalary.findAll", query = "SELECT d FROM DesiredSalary d ORDER BY d.value"),
    @NamedQuery(name = "DesiredSalary.findByIdDesiredSalary", query = "SELECT d FROM DesiredSalary d WHERE d.idDesiredSalary = :idDesiredSalary"),
    @NamedQuery(name = "DesiredSalary.findByDescription", query = "SELECT d FROM DesiredSalary d WHERE d.description = :description")})
public class DesiredSalary implements Serializable, Comparable<DesiredSalary> {
    @OneToMany(mappedBy = "maximumDesiredSalary", fetch = FetchType.LAZY)
    private List<SearchInterestAreaRequerimentOrOperator> searchInterestAreaRequerimentOrOperatorList;
    @OneToMany(mappedBy = "maximumDesiredSalary", fetch = FetchType.LAZY)
    private List<SearchInterestAreaRequerimentAndOperator> searchInterestAreaRequerimentAndOperatorList;
    @Basic(optional = false)
    @NotNull
    @Column(name = "VALUE")
    private int value;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_DESIRED_SALARY")
    private Integer idDesiredSalary;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "DESCRIPTION")
    private String description;
    @OneToMany(mappedBy = "desiredSalary", fetch = FetchType.LAZY)
    private List<CandidateInterestArea> candidateInterestAreaList;

    public DesiredSalary() {
    }

    public DesiredSalary(Integer idDesiredSalary) {
        this.idDesiredSalary = idDesiredSalary;
    }

    public DesiredSalary(Integer idDesiredSalary, String description) {
        this.idDesiredSalary = idDesiredSalary;
        this.description = description;
    }

    public Integer getIdDesiredSalary() {
        return idDesiredSalary;
    }

    public void setIdDesiredSalary(Integer idDesiredSalary) {
        this.idDesiredSalary = idDesiredSalary;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlTransient
    public List<CandidateInterestArea> getCandidateInterestAreaList() {
        return candidateInterestAreaList;
    }

    public void setCandidateInterestAreaList(List<CandidateInterestArea> candidateInterestAreaList) {
        this.candidateInterestAreaList = candidateInterestAreaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDesiredSalary != null ? idDesiredSalary.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DesiredSalary)) {
            return false;
        }
        DesiredSalary other = (DesiredSalary) object;
        if ((this.idDesiredSalary == null && other.idDesiredSalary != null) || (this.idDesiredSalary != null && !this.idDesiredSalary.equals(other.idDesiredSalary))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.DesiredSalary[ idDesiredSalary=" + idDesiredSalary + " ]";
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    @XmlTransient
    public List<SearchInterestAreaRequerimentOrOperator> getSearchInterestAreaRequerimentOrOperatorList() {
        return searchInterestAreaRequerimentOrOperatorList;
    }

    public void setSearchInterestAreaRequerimentOrOperatorList(List<SearchInterestAreaRequerimentOrOperator> searchInterestAreaRequerimentOrOperatorList) {
        this.searchInterestAreaRequerimentOrOperatorList = searchInterestAreaRequerimentOrOperatorList;
    }

    @XmlTransient
    public List<SearchInterestAreaRequerimentAndOperator> getSearchInterestAreaRequerimentAndOperatorList() {
        return searchInterestAreaRequerimentAndOperatorList;
    }

    public void setSearchInterestAreaRequerimentAndOperatorList(List<SearchInterestAreaRequerimentAndOperator> searchInterestAreaRequerimentAndOperatorList) {
        this.searchInterestAreaRequerimentAndOperatorList = searchInterestAreaRequerimentAndOperatorList;
    }

    @Override
    public int compareTo(DesiredSalary ds) {
        Integer thisValue=this.getValue();
        Integer otherValue=ds.getValue();
        return thisValue.compareTo(otherValue);
    }
    
}
